/*
 * BitManager.h
 *
 *  Created on: 27/11/2009
 *      Author: ngonzalez
 */

#ifndef BITMANAGER_H_
#define BITMANAGER_H_

#include <iostream>
#include <string>
#include "StateControl.h"
#include <bitset>
using namespace std;


struct byte{
	unsigned char b:1;
};
		class BitManager {

private:
	StateControl* stateControl;
	empaquetado vecotrPiso[32];
	empaquetado vectorTecho[32];
	bitset<8>* pbyte;
	string compressedString;
	unsigned char byte;
	bool finCompresion;
	bool finDescompresion;
	unsigned int floor;
	unsigned int roof;
	unsigned int integer;
	unsigned int contadorcadena;
	unsigned int contadorByte;
	unsigned int tamanioCadena;
	unsigned int tamanioPading;

	void updateAfterOV();
	void updateAfterUF();

	public: BitManager();

	public: virtual ~BitManager();

	public: void normalize();

	public: string getCompressedString();

	public: unsigned int getNormalizedRoof();

	public: unsigned int getNormalizedFloor();


	public: void setStringToDecompress(string compressedString);

	public: unsigned int getInteger();

	public: int getIntToDescompress();

	public: void setCompressString(string theString);

	public: void setFloor(unsigned int floor);

	public: void setRoof(unsigned int roof);

	public: unsigned int getTamanioCadena();

	public: unsigned int getContadorCadena();

	private: bool interpretCompresedString();

	private: unsigned int asignarBit(unsigned int entero);

	private: void calcularEnteroOV();

	private: void calcularEnteroUF();

	private: void calcularTamanioPading();

	public: bool isFinDescompresion();

	public: unsigned int descomprimirUltimoCaracter(unsigned int entero);
};

#endif /* BITMANAGER_H_ */
